<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>生产工序项目设置</title>
		<link rel="stylesheet" href="/bootstrap/bootstrap-5.3.3-dist/css/bootstrap.min.css" />
		<link rel="stylesheet" href="/css/manufactureCss/Set_production_process_items.css" />
		<style type="text/css">
			
		</style>
	</head>
	<body style="height: 332px">
		<div class="panel product">
			<div class="panel-heading hhead">
				<nav aria-label="breadcrumb">
				  <ol class="breadcrumb">
				  	<span style="color: blue;">您正在做的业务是：</span>
				  	<li class="breadcrumb-item"><a href="#">生产管理</a></li>
				    <li class="breadcrumb-item"><a href="#">产品生产工序设计</a></li>
					  <li class="breadcrumb-item"><a href="#">制定产品生产工序设计单</a></li>
				    <li class="breadcrumb-item active" aria-current="page">添加生产工序</li>
				  </ol>
				</nav>
<%--				<div>--%>
<%--					<p><small>当前等待审核的设计单总数：<span style="color: red;">4</span>例</small></p>--%>
<%--				</div>--%>
			</div>
			<div style="margin-bottom: 2px">
		        <div style="display: inline;margin-left: 89%;">
		        	<button class="btn btn-primary" id="btnAdd" data-bs-toggle="modal" data-bs-target="#levelFirstModal">添加</button>
		            <button class="btn btn-primary">删除</button>
		        </div>
		    </div>
			<div class="panel-body bbody" style="height: 200px">
				<table id="tab" >
					<thead>
						<tr style="background-color: #e8e8e8;">
							<td></td>
							<td>工序项目编号</td>
							<td>工序项目名称</td>
							<td style="width: 400px;">工序项目描述</td>
							<td>负责人编号</td>
							<td>添加</td>
						</tr>
					</thead>
					<tbody id="template">
						<tr>
							<td><input type="checkbox" name="" /></td>
							<td>bbbb</td>
							<td>ccc</td>
							<td>ddd</td>
							<td>fff</td>
							<td><a href="">变更</a></td>
						</tr>
						<tr>
							<td><input type="checkbox" name="" /></td>
							<td>bbbb</td>
							<td>ccc</td>
							<td>ddd</td>
							<td>fff</td>
							<td><a href="">变更</a></td>
						</tr>
						<tr >
							<td><input type="checkbox" name="" /></td>
							<td>bbbb</td>
							<td>ccc</td>
							<td>ddd</td>
							<td>fff</td>
							<td><a href="">变更</a></td>
						</tr>
					</tbody>
				</table>
			</div>
			
			<div class="panel-footer ffooter">
				<div id="footerDiv">
					<label style="font-weight: 700;">总数：<span style="color: red;">5</span>例&nbsp;&nbsp;&nbsp;&nbsp;
						当前第<span style="color: red;">1</span>页&nbsp;&nbsp;&nbsp;&nbsp;
						共<span style="color: red;">1</span>页&nbsp;&nbsp;&nbsp;&nbsp;
					</label>
				</div>
				
			</div>
		</div>

<script type="text/javascript" src="/js/jquery-3.7.0.min.js"></script>
<script type="text/javascript" src="/bootstrap/bootstrap-5.3.3-dist/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript">
		$(function (){
			initialProcedureTable();
		})
		function initialProcedureTable(){
			$.ajax({
				type:"GET",
				url:"/m-procedure-unit/initialProcedureTable",
				async:false,
				dataType:"json",
				success:function (data){
					console.log(data)
					$("#template").empty();
					for (let i = 0; i < data.length; i++) {
						let tr = "<tr>" +
							"<td><input type='checkbox' name='' /></td>" +
							"<td>"+data[i].procedureId+"</td>" +
							"<td>"+data[i].procedureName+"</td>" +
							"<td>"+data[i].procedureDescribe+"</td>" +
							"<td>"+""+"</td>" +
							"<td><a href='javascript:add("  + data[i]["id"]+ ")' class='btn btn-outline-success ' >添加</a>" +
							"</tr>";
						$("#template").append(tr);
					}
				}
			})
		}
		function add(id){
			let IdItems = [];
			if(sessionStorage.getItem("IdItems") != null){
				IdItems = JSON.parse(sessionStorage.getItem("IdItems"));
			}
			if(IdItems.indexOf(id) != -1){
				alert("该工序已添加");
				return;
			}
			IdItems.push(id);
			sessionStorage.getItem("IdItems") == null? sessionStorage.setItem("IdItems",JSON.stringify(IdItems)) : sessionStorage.setItem("IdItems",JSON.stringify(IdItems));
		}

</script>
</body>
</html>
